package edu.njfu.activtiylife

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import edu.njfu.learnkotlin.Md5Util
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        Log.d("MainActivity","TaskId is ${taskId}")
        Log.d("MainAcitvity",javaClass.simpleName)
        button.setOnClickListener {
            /**
             * button.setOnClickListener({}
             * }
             * 1. 果lambada表达式是参数列表的最后一个参数，可以把lambda表达式移出到小括号的
             * 的外面,如下所示：
             * button.setOnClickListener(){
             *      onclick(){
             *      }
             * }
             * 2. 如果java单方法接口，可以省略方法名称，如下所示：
             *  button.setOnClickListener(){
             *      //OnClick,Context
             *  }
             * 3. 如果方法无参，可以省略小括号
             * button.setOnClickListener{
             * }
             */
            val intent= Intent(this,SecondActivity::class.java);
            startActivity(intent)
        }
        button4.setOnClickListener {
            val intent= Intent(this,StandardActivity::class.java);
            startActivity(intent)
        }
        button5.setOnClickListener {
            val intent= Intent(this,SingleTopActivity::class.java);
            startActivity(intent)
        }
        button6.setOnClickListener {
            val intent= Intent(this,SingleTaskActivity::class.java);
            startActivity(intent)
        }
        button7.setOnClickListener {
            val intent= Intent(this,SingleInstanceActivity::class.java);
            startActivity(intent)
        }
        button15.setOnClickListener {
            val username="zhangsan"
            val password:String=Md5Util.stringToMD5("123456")
            Log.d("MainActivity","--------${password}")
            FourthActivity.startActivity(this,username,password)
        }
    }

    override fun onStart() {
        super.onStart()
        /**
         * Log.i  info
         * Log.d  debug 输出日志信息 Logcat  选择debug
         * Log.e  error Logcat 选择Error 查看错误
         * Log.w  warnig
         * Log.v verbose
         */
        Log.d("MainActivity","OnStart()方法被调用")
    }
    override fun onResume() {
        super.onResume()
        Log.d("MainActivity","OnResume()方法被调用")
    }

    override fun onPause() {
        super.onPause()
        Log.d("MainActivity","OnPause()方法被调用")
    }

    override fun onStop() {
        super.onStop()
        Log.d("MainActivity","OnStop()方法被调用")
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.d("MainActivity","OnDestory()方法被调用")
    }

    override fun onRestart() {
        super.onRestart()
        Log.d("MainActivity","OnRetart()方法被调用")
    }
}
